package com.neusoft.dao;

import com.neusoft.entity.ProductOfShopCart;
import com.neusoft.entity.ShopCart;
import com.sun.javafx.collections.MappingChange;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository
public class ShopCartMapperImp implements ShopCartMapper{

    public SqlSessionTemplate getSst() {
        return sst;
    }

    public void setSst(SqlSessionTemplate sst) {
        this.sst = sst;
    }

    @Autowired
    private SqlSessionTemplate sst = null;

    @Override
    public Integer addShopCart(ShopCart shopCart) {
        return sst.insert("addShopCart",shopCart);
    }

    @Override
    public Integer addProductIntoShopCart(ProductOfShopCart ps) {
        return sst.insert("addProductIntoShopCart",ps);
    }

    @Override
    public Integer addProductCount(ProductOfShopCart ps) {
        return sst.insert("addProductCount",ps);
    }

    @Override
    public ShopCart findShopCartById(Integer id) {
        return sst.selectOne("findShopCartById",id);
    }

    @Override
    public ShopCart findShopCartByUserId(Integer userId) {
        return sst.selectOne("findShopCartByUserId",userId);
    }

    @Override
    public ProductOfShopCart findProdutOfShopCart(Map<String, Object> map) {
        return sst.selectOne("findProdutOfShopCart",map);
    }
}
